
let express = require('201901/10.express/express');

// 路由参数
let real = '/user/4/jw';
let str = '/user/:id/:name';

let args = [];
str = str.replace(/:([^\/]*)/g,function () {
  args.push(arguments[1]);
  return `([^\/]*)`
})

console.log(str)
let reg = new RegExp(str);

let [,...lists]= real.match(reg);


let result = args.reduce((memo,arg,index)=>(memo[arg]=lists[index],memo),{})
console.log(result)


let app = express();
